<template>
  <div> <!--<div id='radar'>-->
    <div ref="radar" style="height: 400px;" />
  </div>
</template>
<script>
import * as echarts from 'echarts/core'
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent
} from 'echarts/components'
import { PieChart } from 'echarts/charts'
import { LabelLayout } from 'echarts/features'
import { CanvasRenderer } from 'echarts/renderers'

echarts.use([
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  PieChart,
  CanvasRenderer,
  LabelLayout
])

export default {
  mounted() {
    // var chartDom = document.getElementById('radar')
    var chartDom = this.$refs.radar
    var myChart = echarts.init(chartDom)
    var option

    option = {
      title: {
        text: '价格数量分布',
        textStyle: {
          color: '#000'
        }
      },
      tooltip: {
        trigger: 'item'
      },
      legend: {
        top: '5%',
        left: 'center'
      },
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: ['40%', '70%'],
          avoidLabelOverlap: false,
          label: {
            show: false,
            position: 'center'
          },
          emphasis: {
            label: {
              show: true,
              fontSize: 40,
              fontWeight: 'bold'
            }
          },
          labelLine: {
            show: false
          },
          data: [
            { value: 1048, name: '公寓' },
            { value: 735, name: '别墅' },
            { value: 580, name: '楼房' }
          ]
        }
      ]
    }

    option && myChart.setOption(option)
  }
}
</script>
<style scoped>
/* #radar{
      height: 400px;
  } */
</style>

